<?php
class MHDEV_View_Helper_GetThreadStatus extends Zend_View_Helper_Abstract
{
	public function GetThreadStatus($uid)
	{
		// vars
		$user_uid = Zend_Auth::getInstance()->hasIdentity() ? Zend_Auth::getInstance()->getIdentity()->uid : 0;
		
		// helper
		$bUrl	= new MHDEV_View_Helper_BaseUrl();
		
		// db
		$threads_visited 	= new ThreadsVisit();
		$threads			= new Threads();
		
		// query
		$getThread	= $threads->find($uid);
		
		if($getThread->count() > 0)
		{
			$resThread 	= $getThread->toArray();
			$lastReply 	= $resThread[0]['last_reply_date'];
			
			$query		= $threads_visited->fetchAll('user_uid = ' . $user_uid . ' AND thread_uid=' . $uid);
			
			if($query->count() > 0)
			{
				$resVThread = $query->toArray();
				
				if($resVThread[0]['date'] < $lastReply)
				{
					$content = '<img src="' . $bUrl->baseurl() . '/static/gfx/thread_1.png" />';
				}
				else
				{
					$content = '<img src="' . $bUrl->baseurl() . '/static/gfx/thread_0.png" />';
				}
			}
			else
			{
				$content = '<img src="' . $bUrl->baseurl() . '/static/gfx/thread_1.png" />';
			}
		}

		return $content;
	}
}
?>